/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.lostreseditores.modelo;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author DILOVE
 */
@Entity
@Table(name = "contextopregunta")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Contextopregunta.findAll", query = "SELECT c FROM Contextopregunta c"),
    @NamedQuery(name = "Contextopregunta.findByIdContexto", query = "SELECT c FROM Contextopregunta c WHERE c.idContexto = :idContexto"),
    @NamedQuery(name = "Contextopregunta.findByNombrecontexto", query = "SELECT c FROM Contextopregunta c WHERE c.nombrecontexto = :nombrecontexto")})
public class Contextopregunta implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_contexto")
    private Integer idContexto;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "nombrecontexto")
    private String nombrecontexto;
    @Lob
    @Column(name = "imagen")
    private byte[] imagen;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idContexto")
    private List<Pregunta> preguntaList;

    public Contextopregunta() {
    }

    public Contextopregunta(Integer idContexto) {
        this.idContexto = idContexto;
    }

    public Contextopregunta(Integer idContexto, String nombrecontexto) {
        this.idContexto = idContexto;
        this.nombrecontexto = nombrecontexto;
    }

    public Integer getIdContexto() {
        return idContexto;
    }

    public void setIdContexto(Integer idContexto) {
        this.idContexto = idContexto;
    }

    public String getNombrecontexto() {
        return nombrecontexto;
    }

    public void setNombrecontexto(String nombrecontexto) {
        this.nombrecontexto = nombrecontexto;
    }

    public byte[] getImagen() {
        return imagen;
    }

    public void setImagen(byte[] imagen) {
        this.imagen = imagen;
    }

    @XmlTransient
    public List<Pregunta> getPreguntaList() {
        return preguntaList;
    }

    public void setPreguntaList(List<Pregunta> preguntaList) {
        this.preguntaList = preguntaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idContexto != null ? idContexto.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Contextopregunta)) {
            return false;
        }
        Contextopregunta other = (Contextopregunta) object;
        if ((this.idContexto == null && other.idContexto != null) || (this.idContexto != null && !this.idContexto.equals(other.idContexto))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.lostreseditores.modelo.Contextopregunta[ idContexto=" + idContexto + " ]";
    }
    
}
